<!DOCTYPE html>
<html>
  
  <head>
    <meta charset="UTF-8">
    {include="style"}
  </head>
  
  <body>
	<div class="x-nav">
            <span class="layui-breadcrumb">
              <a><cite>{fun JZLANG('首页')}</cite></a>
              <a><cite>{fun JZLANG('管理员管理')}</cite></a>
             
			 <a><cite>{fun JZLANG('角色管理')}</cite></a>
			 <a><cite>{fun JZLANG('角色修改')}</cite></a>
            </span>
            <a class="layui-btn layui-btn-small" style="line-height:1.6em;margin-top:3px;float:right"  href="javascript:location.replace(location.href);" title="{fun JZLANG('刷新')}"><i class="iconfont" style="line-height:30px">&#xe6aa;</i></a>
    </div>
    <div class="x-body">
		<div class="layui-card">
		<div class="layui-card-body">
        <form  method="post" class="layui-form layui-form-pane">
			<input type="hidden" name="go" value="1" />
                <div class="layui-form-item">
                    <label for="name" class="layui-form-label">
                        {fun JZLANG('角色名')}
                    </label>
                    <div class="layui-input-inline">
                        <input type="text" id="name" name="name" required="" lay-verify="required"
                        autocomplete="off" class="layui-input">
                    </div>
                </div>
			{if($admin['gid']==1)}
				<div class="layui-form-item" pane>
                    <label for="isadmin" class="layui-form-label">
                        <span class="x-red"></span>{fun JZLANG('是否超管')}
                    </label>
                    <div class="layui-input-inline">
                        <input type="radio" name="isadmin" value="0" title="{fun JZLANG('不是')}" checked>
						<input type="radio" name="isadmin" value="1" title="{fun JZLANG('是')}" >
                    </div>
					<div class="layui-form-mid layui-word-aux">
					  {fun JZLANG('超级管理员拥有无上权利，无视下面权限限制')}
					</div>
					
                </div>
			{else}
			<input type="hidden" name="isadmin" value="0">
			{/if}
				<div class="layui-form-item" pane>
                    <label for="ischeck" class="layui-form-label">
                        <span class="x-red"></span>{fun JZLANG('发布审核')}
                    </label>
                    <div class="layui-input-inline">
                        <input type="radio" name="ischeck" value="0" title="{fun JZLANG('否')}" checked>
						<input type="radio" name="ischeck" value="1" title="{fun JZLANG('是')}" >
                    </div>
					<div class="layui-form-mid layui-word-aux">
					  {fun JZLANG('超级管理员除外，发布的内容是否需要审核')}
					</div>
					
                </div>
				<div class="layui-form-item" pane>
                    <label for="classcontrol" class="layui-form-label">
                        <span class="x-red"></span>{fun JZLANG('栏目权限')}
                    </label>
                    <div class="layui-input-inline">
                        <input type="radio" name="classcontrol" value="0" title="{fun JZLANG('否')}" checked>
						<input type="radio" name="classcontrol" value="1" title="{fun JZLANG('是')}" >
                    </div>
					<div class="layui-form-mid layui-word-aux">
					  {fun JZLANG('是否设置栏目权限，默认不设置。开启后下面的栏目权限设置才有效')}
					</div>
					
                </div>
				<div class="layui-form-item layui-form-text">
                    <label class="layui-form-label">
                        {fun JZLANG('栏目权限')} <span class="x-red">{fun JZLANG('选中顶级栏目，则默认子栏目也选中。如果只需要子栏目权限，请不要选中顶级栏目')}</span>
                    </label>
                    <table  class="layui-table layui-input-block">
                        <tbody>
							<tr>
                                <th>
                                   {fun JZLANG('顶级栏目')}
                                </th>
                                <th>
                                   {fun JZLANG('子栏目')}
                                </th>
                            </tr>
						{foreach $classtypetree as $v}
						{if($v['pid']==0)}
                            <tr>
                                <td>
                                    <input type="checkbox" name="tids[]" lay-skin="primary" value="{$v['id']}" title="{$v['classname']}" checked>
                                </td>
                                <td>
                                    <div class="layui-input-block">
                                    {php $children = get_children($v,$classtypetree,5);/}
									{foreach $children as $vv}
                                        <input name="tids[]" lay-skin="primary" type="checkbox" title="{$vv['classname']}" value="{$vv['id']}" > 
									{/foreach}
                                        
                                    </div>
                                </td>
                            </tr>
                        {/if}
						{/foreach}
                           
                        </tbody>
                    </table>
                </div>
                <div class="layui-form-item layui-form-text">
                    <label class="layui-form-label">
                        {fun JZLANG('拥有权限')}  <span class="x-red">{fun JZLANG('选中主模块，则默认子模块也选中。如果只需要子模块权限，请不要选中主模块')}</span>
                    </label>
                    <table  class="layui-table layui-input-block">
                        <tbody>
							<tr>
                                <th>
                                   {fun JZLANG('主模块')}
                                </th>
                                <th>
                                   {fun JZLANG('子模块')}
                                </th>
                            </tr>
						{foreach $ruler_top as $v}
                            <tr>
                                <td>
                                    <input type="checkbox" name="ruler[]" lay-skin="primary" value="{$v['fc']}" title="{$v['name']}" checked>
                                </td>
                                <td>
                                    <div class="layui-input-block">
									{foreach $ruler_children[$v['id']] as $vv}
                                        <input name="ruler[]" lay-skin="primary" type="checkbox" title="{$vv['name']}" value="{$vv['fc']}" > 
									{/foreach}
                                        
                                    </div>
                                </td>
                            </tr>
						{/foreach}
                           
                        </tbody>
                    </table>
                </div>
                <div class="layui-form-item layui-form-text">
                    <label for="description" class="layui-form-label">
                        {fun JZLANG('描述')}
                    </label>
                    <div class="layui-input-block">
                        <textarea placeholder="{fun JZLANG('请输入内容')}" id="description" name="description" class="layui-textarea"></textarea>
                    </div>
                </div>
				<div class="layui-form-item" pane>
                    <label for="isagree" class="layui-form-label">
                        <span class="x-red"></span>{fun JZLANG('状态')}
                    </label>
                    <div class="layui-input-inline">
                        <input type="radio" name="isagree" value="0" title="{fun JZLANG('关闭')}" >
						<input type="radio" name="isagree" value="1" title="{fun JZLANG('开启')}" checked>
                    </div>
					<div class="layui-form-mid layui-word-aux">
					  {fun JZLANG('关闭后，该分组管理员将不能登录')}
					</div>
					
                </div>
				
                <div class="layui-form-item" style="text-align:center;">
                <button class="layui-btn" lay-submit="" lay-filter="add">{fun JZLANG('添加')}</button>
              </div>
            </form>
			</div>
			</div>
    </div>
    <script>
        layui.use(['form','layer'], function(){
            $ = layui.jquery;
          var form = layui.form
          ,layer = layui.layer;
        
          form.render();

          //监听提交
          form.on('submit(add)', function(data){
            $.post("{fun U('Admin/groupadd')}",data.field,function(r){
				var r = JSON.parse(r);
				if(r.code==0){
					 layer.msg(r.msg, {icon: 6,time: 2000},function () {
						// 获得frame索引
						{if($webconf['admintpl']=='tpl')}
						window.location.href="{fun U('Admin/group')}";
						{else}
						parent.location.reload();
						{/if}
					});
				}else{
					layer.alert(r.msg, {icon: 5});
				}
			});
			
            return false;
          });
          
          
        });
    </script>
    
  </body>

</html>